import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class testcode {
    public static void main(String[] args) {
        test01();
    }

    public static void test01() {
        ChromeDriver webdriver = new ChromeDriver();
        webdriver.get("https://www.baidu.com");
        WebElement element = webdriver.findElement(By.cssSelector("#kw"));
        element.sendKeys("selenium");
        String text = webdriver.findElement(By.cssSelector("#s-top-left > div > a")).getText();
        System.out.println("获取到的文本:" + text);
    }
}
